// import Cookies from 'js-cookie'
import StorageUtil from "@/utils/StorageUtil";

const TokenKey = '_Admin-Token-1'
const TokenRefreshKey = '_Admin-RefreshToken-1'
const AuthsKey = '_Admin-Auths-1'
const UserKey = '_Admin-User-1'

export function setToken(token) {
  StorageUtil.save(TokenKey, token)
}
export function getToken() {
  return StorageUtil.readStr(TokenKey)
}
export function removeToken() {
  StorageUtil.remove(TokenKey)
}

export function setRefreshToken(refreshToken) {
  StorageUtil.save(TokenRefreshKey, refreshToken)
}
export function getRefreshToken() {
  return StorageUtil.readStr(TokenRefreshKey)
}
export function removeRefreshToken() {
  StorageUtil.remove(TokenRefreshKey)
}

export function setAuths(auths) {
  StorageUtil.save(AuthsKey, auths)
}
export function getAuths() {
  return StorageUtil.readArr(AuthsKey)
}
export function removeAuths() {
  StorageUtil.remove(AuthsKey)
}

export function setUser(user) {
  StorageUtil.save(UserKey, user)
}
export function getUser() {
  return StorageUtil.readObj(UserKey)
}
export function removeUser() {
  window.localStorage.removeItem(UserKey)
}


export function clearAuthCache() {
  removeAuths()
  removeRefreshToken()
  removeToken()
  removeUser()
}

